﻿using FangPage.Core;
using FangPage.Data;
using FangPage.User;
using FangPage.User.Model;
using System;
using System.Collections.Generic;
using System.Text;

namespace FangPage.User.Controller
{
    public class depart_list : UserController
    {
        public override void Controller()
        {
            string name = FPRequest.GetString("name");

            if (ispost)
            {
                string ids = FPRequest.GetString("ids");

                DbHelper.ExcuteDelete<Department>(ids);

                FPResponse.WriteSuccess("删除成功");
                return;
            }

            List<SqlParam> where = new List<SqlParam>();

            if (name != "")
            {
                where.Add(DbHelper.MakeAndWhere("name", WhereType.Like, name));
            }

            where.Add(DbHelper.MakeOrderBy("display", OrderBy.ASC));

            List<Department> data = DbHelper.ExcuteList<Department>(where.ToArray());

            FPResponse.WriteData(data);
        }
    }
}
